<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑电影</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/backstage/css/font.css">
    <link rel="stylesheet" href="/backstage/css/xadmin.css">

    <style>
        /* .layui-form-label{
            width:120px;
        } */
        /*.layui-form-item{border-bottom:1px solid #ccc;padding-top:5px;}*/
    </style>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>影片名称
            </label>
            <div class="layui-input-block">
                <input type="text" id="title" value="{$info.title}" name="title" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>封面图
            </label>
            <div class="layui-input-block">
                <input type="text"  name="poster" value="{$info.poster}" oninput="changeImg(this)" placeholder="请输入图片链接" lay-verify="required" autocomplete="off" class="layui-input">

                <img src="{$info.poster}" alt="" width="250px" id="poster">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>视频链接
            </label>
            <div class="layui-input-block">
                <input type="text" value="{$info.url}"  name="url" placeholder="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>链接类型</label>
            <div class="layui-input-block">
                <input type="radio" name="url_type" value="1" title="正常链接"  {if $info.url_type==1} checked="checked" {/if}>
                <input type="radio" name="url_type" value="2" title="iframe" {if $info.url_type==2} checked="checked" {/if}>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="pid" class="layui-form-label">
                <span class="x-red"></span>影片类型
            </label>
            <div class="layui-input-inline">
                <select name="movie_type">
                    <option value='0'>请选择</option>
                    {foreach name="types" item="row"}
                    <option value="{$row['id']}" {if $info.movie_type==$row.id} selected="selected"{/if}>{$row['type_name']}</option>
                    {/foreach}
                </select>
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>上映年份</label>
            <div class="layui-input-inline">
                <input class="layui-input" id="year" value="{$info.movie_year}" name="movie_year">

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>上映日期</label>
            <div class="layui-input-inline">
                <input class="layui-input" placeholder="" value="{$info.movie_time|date='Y-m-d'}" name="movie_time" id="start">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="pid" class="layui-form-label">
                <span class="x-red"></span>影片地区
            </label>
            <div class="layui-input-inline">
                <select name="region_id">
                    <option value='0'>请选择</option>
                    {foreach name="regions" item="row"}
                    <option value="{$row['id']}" {if $info.region_id==$row.id} selected="selected"{/if}>{$row['region_name']}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="pid" class="layui-form-label">
                <span class="x-red"></span>语言
            </label>
            <div class="layui-input-inline">
                <select name="language">
                    <option value=''>请选择</option>
                    {foreach name="languages" item="row"}
                    <option value="{$row}" {if $info.language==$row} selected="selected"{/if}>{$row}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>评分</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" maxlength="3" value="{$info.grade}"  name="grade">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>分辨率</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" value="{$info.resolution}"  name="resolution">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>主演</label>
            <div class="layui-input-block">
                <input class="layui-input" value="{$info.actors}" type="text" name="actors">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>导演</label>
            <div class="layui-input-block">
                <input class="layui-input" type="text" value="{$info.directors}" name="directors">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="desc" class="layui-form-label">
                剧情描述
            </label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容"  name="content" class="layui-textarea">{$info.content}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>是否热门</label>
            <div class="layui-input-block">
                <input type="radio" name="is_hot" value="1" title="是" {if $info.is_hot==1} checked="checked"{/if} >
                <input type="radio" name="is_hot" value="0" title="否" {if $info.is_hot==0} checked="checked"{/if}>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>是否推荐</label>
            <div class="layui-input-block">
                <input type="radio" name="is_recommend" value="1" title="是" {if $info.is_recommend==1} checked="checked"{/if}>
                <input type="radio" name="is_recommend" value="0" title="否" {if $info.is_recommend==0} checked="checked"{/if}>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span>上架状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="上架" {if $info.status ==1} checked="checked"{/if}>
                <input type="radio" name="status" value="2" title="下架" {if $info.status != 1} checked="checked"{/if}>
            </div>
        </div>


        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="upd" lay-submit="" type="button">
                确认提交
            </button>
        </div>
        <input type="hidden" value="{$info['id']}" name="id">

        {:token()}
    </form>
</div>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/backstage/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/backstage/js/xadmin.js"></script>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        //自定义验证规则
        form.verify({
            required: function (value) {
                if (value == '') {
                    return '此选项不能为空'
                }
            },
        });
        //监听提交
        form.on('submit(upd)', function (data) {

            $.post('{:rootPath()}/movies/update/' + data.field.id, data.field, function (res) {
                if (res.code == '200') {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    // 关闭当前frame
                    parent.layer.close(index);
                    parent.layer.msg("修改成功", {icon: 6, time: 1000});
                    parent.app.getListData();
                    parent.app.page();
                } else {
                    layer.msg(res.msg, {icon: 5, time: 1000});
                }

            }, 'json');

        });

    });
    layDate();

    function changeImg(obj){
        $('#poster').attr('src',$(obj).val());
    }
</script>

</body>

</html>